<template>
  <div>
    <van-list
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
        >
        <CommentPage2List
        v-for="item in list"
        :key="item.commentId"
        :CommentId="item.commentId"
        :UserId="item.userId"
        :UserName="item.userName"
        :UserIcon="item.userIcon"
        :MusicId="item.musicId"
        :CommentText="item.commentText"
        :CountLike = "item.countLike"
        :AddTime = "item.addTime"
        >
        </CommentPage2List>
    
        <!-- ></Musicpage2list> -->

    </van-list>

    
  </div>
</template>

<script>
import CommentAPI from '@/api/CommentAPI'
// import { type } from 'os'
// import Musicpage2list from '../Musicpage2list.vue';
import CommentPage2List from './CommentPage2List.vue';



export default {
    name: "CommentList",
    components: { 
      // Musicpage2list, 
      CommentPage2List },
    data() {
        return {
            list: [],
            musicId: "",
            loading: false,
           finished: false,
        };
    },
    // props: {
    //   musicId: {
    //   required: true,
    //   type: String
    // },
    // },

    props:{
     ItMusicId:{
      required: true,
      type: String
    },
    },
    created() {
        // CommentAPI.
        // getMusicId(); 
        this.musicId =this.ItMusicId
      // getMusicId2CommentList()
      var result = CommentAPI.getCommentByMusicId(this.ItMusicId);
            // 获取返回结果
            result.then((val) => {
                console.log(val);
                if (val.success) {
                    // 将数据存到list里面
                    this.list = val.data;
                }
                else {
                    console.log(val.errorMsg);
                    this.$toast(val.errorMsg);
                }
            });
     
    },
    mounted() {
    //  this.musicId =this.ItMusicId
    //   // getMusicId2CommentList()
    //   getCommentList(this.ItMusicId)
    // getCommentList(this.ItMusicId)
    },

    methods: {
        getCommentList(id) {
            var result = CommentAPI.getCommentByMusicId(id);
            // 获取返回结果
            result.then((val) => {
                console.log(val);
                if (val.success) {
                    // 将数据存到list里面
                    this.list = val.data;
                }
                else {
                    console.log(val.errorMsg);
                    this.$toast(val.errorMsg);
                }
            });
        },

    },

}
</script>

<style lang="less">

</style>